import Vue from 'vue'
import VueRouter from 'vue-router'
import Footer from '@/components/Footer'

Vue.use(VueRouter)
const routes = [
  { // 路由跟组件时映射关系
    path: '/',
    redirect: '/home'
  },
  {
    path: '/user',
    name: 'user',
    components: { // 一个路由 对象两个位置发生变化
      default: () => import('@/views/user/index.vue'),
      footer: Footer
    }
  },
  {
    path: '/coupon',
    name: 'coupon',
    component: () => import('../views/coupon/index.vue')
  },
  { // 路由跟组件时映射关系
    path: '/index',
    name: 'index',
    // 路由的懒加载
    components: { // 一个路由 对象两个位置发生变化
      default: () => import('@/views/index/index.vue'),
      footer: Footer
    }
  },
  {
    path: '/login',
    name: 'login',
    components: {
      default: () => import('../views/login/index.vue')
    }
  },
  {
    path: '/couponx',
    name: 'couponx',
    components: {
      default: () => import('../views/coupon/couponx.vue')
    }
  },
  {
    path: '/register',
    name: 'register',
    components: {
      default: () => import('../views/register/index.vue')
    }
  },
  {
    path: '/vip',
    name: 'vip',
    components: {
      default: () => import('../views/vip/index.vue')
    }
  },
  {
    path: '/address',
    name: 'address',
    components: {
      default: () => import('../views/address/index.vue')
    }
  },
  {
    path: '/addsite',
    name: 'addsite',
    components: {
      default: () => import('../views/address/add.vue')
    }
  },
  {
    path: '/order/:active',
    name: 'order',
    components: {
      default: () => import('../views/order/index.vue')
    }
  },
  {
    path: '/about',
    name: 'about',
    component: () => import('@/views/user/About.vue')
  },
  {
    path: '/goods',
    name: 'goods',
    components: { // 一个路由 对象两个位置发生变化
      default: () => import('@/views/goods/index.vue'),
      footer: Footer
    }
  },
  {
    path: '/cart',
    name: 'cart',
    components: { // 一个路由 对象两个位置发生变化
      default: () => import('@/views/cart/index.vue'),
      footer: Footer
    }
  },
  {
    path: '/store',
    name: 'store',
    components: { // 一个路由 对象两个位置发生变化
      default: () => import('@/views/store/index.vue'),
      footer: Footer
    }
  },
  {
    path: '/integral',
    name: 'integral',
    components: { // 一个路由 对象两个位置发生变化
      default: () => import('@/views/integral/index.vue')
    }
  },
  {
    path: '/integralInfo',
    name: 'integralInfo',
    components: { // 一个路由 对象两个位置发生变化
      default: () => import('@/views/integral/integralInfo.vue')
    }
  },
  {
    path: '/home',
    name: 'home',
    components: { // 一个路由 对象两个位置发生变化
      default: () => import('@/views/home/index.vue'),
      footer: Footer
    }
  },
  {
    path: '/footprint',
    name: 'footprint',
    components: {
      default: () => import('@/views/footprint/index.vue')
    }
  },
  {
    path: '/detail/:proid',
    name: 'detail',
    components: {
      default: () => import('@/views/detail/index.vue')
    }
  },
  {
    path: '/detailProduct',
    name: 'detail',
    components: {
      default: () => import('@/views/detailProduct/index.vue')
    }
  },
  {
    path: '/user/findpwd',
    name: 'findpwd',
    components: {
      default: () => import('../views/login/findpwd.vue')
    }
  },
  {
    path: '/decision',
    name: 'decision',
    components: {
      default: () => import('../views/cart/decision.vue')
    }
  },
  {
    path: '/paymethods',
    name: 'paymethods',
    component: () => import('../views/paymethods/index.vue')
  },
  {
    path: '/kindRight',
    name: 'kindRight',
    component: () => import('@/views/kindRight/index.vue')
  },
  {
    path: '/kindLeft',
    name: 'kindLeft',
    component: () => import('@/views/kindLeft/index.vue')
  },
  {
    path: '/searchLeft',
    name: 'searchLeft',
    component: () => import('@/views/searchLeft/index.vue')
  },
  {
    path: '/searchRight',
    name: 'searchRight',
    component: () => import('@/views/searchRight/index.vue')
  },
  {
    path: '/collection',
    name: 'collection',
    component: () => import('@/views/collection/index.vue')
  }
]
const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

export default router
